Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
helper-js
Advanced tools
js functions, just import needed functions.
js 方法库, 按需使用
// install
npm install helper-js -S
import {function1, function2} from 'helper-js'
typeof v !== 'undefined'
Object.prototype.toString.call(v) === '[object Array]'
(10, 3) => '010', (2, 4) => '0002'
(1, 10) => 10, (11, 10) => 11
(1, 10) => 1, (11, 10) => 10
hello => Hello
helloWorld nice => hello-world-nice
helloWorld nice => hello_world_nice
helloWorld nice => helloWorldNice
helloWorldNice => hello World nice
helloWorldNice => Hello World Nice
({'1': '2', '3': '4'}, 'abcd1234') => 'abcd2244'
handler(item, index/key)
({a:{b:1}}, 'a.b') => 1
return cloned obj
handler(value, key, parent)
handler can return null or an object.
null: don't change anything
object{
key: false, // delete. Deprecated, this will be removed in future, please use `delete` instead of it.
key: new key, // use a new key instead of old key. if key == null, the old key will be detected
delete,
value, // new value. if value not gived, the old value will be detected
skip, // skip children
stop,
}
{key: false}: delete
{value}: change value
{key, value}. change key and value
limit: to prevent circular reference.
idKey(item, i)
eg: mapObjects([{id: 1}, {id:2}], 'id') -> {'1':{id:1},'2':{id:2}}
eg: mapObjects([{id: 1}, {id:2}], (item, i) => item.id + 100 ) -> {'101':{id:1},'102':{id:2}}
handler(node, index, parent, path)
// path: [0, 1]
return 'skip children', 'skip siblings', false // retrun false to stop
childrenKey = 'children'
data
constructor(data)
get rootChildren()
* iteratePath(path, opt = {})
opt.reverse // bool
getNode(path)
getNodeIndexAndParent(path)
return {parent, parentPath, index}
getNodeParent(path)
setPathNode(path, node)
removeNode(path)
walk(handler, opt={})
handler(node, index, parent, path)
clone(opt={})
opt.afterNodeCreated(newNode, {oldNode: node, index, parent, path})
opt: {
immediate: false,
}
next
manuallyopt: {
noCache: false,
}
// type: year, month, day, hour, minute, second, millisecond
addDate(now, 1, 'day')
addDate(now, -1, 'hour')
// callback(mid, i) should return mid - your_value
types eg: ['Object', (i) => i > 3, ['Number', default] ]
resolveArgsByType([1,'str'], ['Number', 'Boolean' ,'String']) -> [1, null, 'str']
resolveArgsByType([1,'str'], ['Number', ['Boolean', true] ,'String']) -> [1, true, 'str']
check source code to learn more
const cwep = new CrossWindowEventProcessor()
// CrossWindowEventProcessor has a default name; communicate in same-name instances.
// don't create more than one same-name instances in one window
// set different name if there are more than one same-name instances
cwep.storageName = '_crossWindow_channel2'
// functions
// on, once, off: same to EventProcessor
// emitTo(name, targets, ...args)
// emitLocal(name, ...args) emit to current window
// broadcast(name, ...args) emit to other windows
// emit(name, ...args) emit to all windows
FAQs
js functions, import on demand. TypeScript supported. [API](https://phphe.github.io/helper-js/)
The npm package helper-js receives a total of 8,182 weekly downloads. As such, helper-js popularity was classified as popular.
We found that helper-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.